local xingluan = fk.CreateSkill {

  name = "joy__xingluan",

  tags = {  },

}



xingluan:addEffect(fk.CardUseFinished, {
  name = "joy__xingluan",
  anim_type = "drawcard",
  events = {fk.CardUseFinished},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(xingluan.name) and player.phase == Player.Play and
    data.tos and #data:getAllTargets() == 1 and player:usedSkillTimes(xingluan.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = room:getCardsFromPileByRule(".|6",2,"drawPile")
    if #cards > 0 then
      local ids , _ = U.askforChooseCardsAndChoice(player,cards, {"OK"}, xingluan.name, "选择一张牌获得",nil, 1, 1,cards)
      local card
      if #ids > 0 then
        card = ids
      else
        card = table.random(cards,1)
      end
      table.removeOne(cards,card[1])
      room:moveCards({
        ids = card,
        to = player.id,
        toArea = Card.PlayerHand,
        moveReason = fk.ReasonPrey,
        proposer = player.id,
        skillName = xingluan.name,
      })
      if #cards > 0 then
        room:moveCards({
          ids = cards,
          toArea = Card.DiscardPile,
          moveReason = fk.ReasonJustMove,
          proposer = player.id,
          skillName = xingluan.name,
        })
      end
    else
      player:drawCards(6, xingluan.name)
    end
  end,
})

return xingluan